package com.xcesys.extras.test.ws;

import java.util.HashMap;
import java.util.Map;

import org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor;
import org.apache.ws.security.WSConstants;
import org.apache.ws.security.handler.WSHandlerConstants;

public class AcegiWSS4JOutInterceptor extends WSS4JOutInterceptor {
	public AcegiWSS4JOutInterceptor() {
		this(null);
	}

	public AcegiWSS4JOutInterceptor(Map<String, Object> props) {
		super(props);
		if (props == null)
			props = new HashMap<String, Object>();
		String uid = "admin";
		// NOTE: The ACTION is also set in the WSSAcegiPropagationAdvice
		if (props.get(WSHandlerConstants.ACTION) == null)
			props.put(WSHandlerConstants.ACTION,
					WSHandlerConstants.USERNAME_TOKEN);
		if (props.get(WSHandlerConstants.PASSWORD_TYPE) == null)
			props.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_TEXT);
		if (props.get(WSHandlerConstants.USER) == null)
			props.put(WSHandlerConstants.USER, uid);
		if (props.get(WSHandlerConstants.PW_CALLBACK_CLASS) == null)
			props.put(WSHandlerConstants.PW_CALLBACK_CLASS,
					ClientPasswordHandler.class.getName());
		setProperties(props);
	}
}
